<% layout('/layouts/default.html', {title: '考核自评查看', libs: ['dataGrid','fileupload','validate']}){ %>
<style>
    .title-right {
        display: inline;
        float: right;
        overflow: hidden;
    }
</style>
<div class="main-content">
    <div class="box box-main">
        <#form:form id="inputForm" model="${examSumScore}" action="${ctx}/exam/dcSupExamSumScoreResult/checkIndexData" method="post" class="form-horizontal">
        <div class="box-header" style="margin-bottom: 0px;">
            <div class="title-right" >
                    <span class="required hide">*</span> ${text('报送时间')}：<i
                        class="fa icon-question hide"></i></label>
                    <label  style="font-size: 12px">${noticeEndTime}</label>
            </div>
        </div>
        <div class="box-body">
            <table id="dataGrid"></table>
            <!--信息主体-->
            <div class="row">
                <!--基本任务信息-->
                <div class="col-xs-12">
                    <div class="form-group">
                        <label class="control-label col-sm-2" title="">
                            <span class="required hide">*</span> ${text('联系人')}：<i
                                class="fa icon-question hide"></i></label>
                        <div class="col-sm-10">
                            <label class="control-label">${contactName}</label>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-xs-12">
                    <div class="form-group">
                        <label class="control-label col-sm-2" title="">
                            <span class="required hide">*</span> ${text('联系电话')}：<i
                                class="fa icon-question hide"></i></label>
                        <div class="col-sm-10">
                            <label class="control-label">${contactPhone}</label>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-xs-12">
                    <div class="form-group">
                        <label class="control-label col-sm-2" title="">
                            <span class="required hide">*</span> ${text('相关附件')}：<i
                                class="fa icon-question hide"></i></label>
                        <div class="col-sm-10">
                            <#form:fileupload id="uploadFile" bizKey="${id}" bizType="dcSupExamScore_file"
                            uploadType="all" class="required" readonly="true" preview="custom"/>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </#form:form>
</div>
</div>
<% } %>
<script>
    // 初始化DataGrid对象
    $('#dataGrid').dataGrid({
        // searchForm: $("#searchForm"),
        data: ${toJson(checkIndexDataDtoPage)},
        datatype: 'local',
        columnModel: [
            {header: '${text("主键")}', name: 'examId', hidden: true},
            {header: '${text("年度")}', name: 'examYear', width: 150, align: "center"},
            {header: '${text("类别")}', name: 'quotaType', width: 100, align: "center",
                formatter: function(val, obj, row, act){
                    return js.getDictLabel(${@DictUtils.getDictListJson('dc_quotaType')},
                        val, '${text("'+val+'")}', true);
                }, edittype:'select', editoptions:{'class':'form-control',
                    items: $.merge([{dictLabel:'&nbsp;',dictValue:''}],
                        ${@DictUtils.getDictListJson('dc_quotaType')}),
                    itemLabel: 'dictLabel', itemValue: 'dictValue', dataInit: function(element){
                        $(element).select2().on("change",function(){$(this).resetValid()});
                    }
                }
            },
            {header: '${text("序号")}', name: 'sortNum', width: 100, align: "center"},
            {header: '${text("目标内容")}', name: 'quotaContent', width: 100, align: "center"},
            {header: '${text("单位")}', name: 'quotaUnit', width: 100, align: "center"},
            {header: '${text("权数")}', name: 'quotaWeight', width: 100, align: "center"},
            {header: '${text("本年度目标")}', name: 'currentYaerGoal', width: 100, align: "center"},
            {header: '${text("备注")}', name: 'remarks', width: 100, align: "center"},
            {header: '${text("自评分数")}', name: 'quotaScore', width: 100, align: "center",
                formatter: function(val, obj, row, act){
                    return Number(val).toFixed(3);
                }
            },
        ],
        editGrid: false,
        // 是否显示行号
        showRownum: false,
        // 列表是否允许排序
        sortableColumn: false,
        // 是否显示底部合计行
        showFooter: true,
        // 表格内没有数据的时候是否提示 “无数据显示”
        emptyDataHint: true,
        // 加载成功后执行事件
        ajaxSuccess: function (data) {
            refreshZpCount();
        }
    });

    function refreshZpCount(){
        let data = $('#dataGrid').dataGrid('getRowData');
        let allQuotaWeight=0;
        let allQuotaScore=0;
        for (let i = 0; i < data.length; i++) {
            allQuotaWeight+=parseFloat(data[i].quotaWeight||0);
            allQuotaScore+=parseFloat(data[i].quotaScore||0);
        }
        $('#dataGrid').dataGrid("footerData", "set", {
            "quotaUnit" : "<center><span>汇总：</span></center>",
            "quotaWeight" : "<span>&nbsp;"+allQuotaWeight+" &nbsp;</span>分",
            "quotaScore": "<span>&nbsp;"+Number(allQuotaScore).toFixed(3)+" &nbsp;</span>分"
        }, false);
    }
</script>